import java.util.ArrayList;
import java.util.LinkedList;
import java.util.TreeMap;


public class Test {

	public static void main(String[] args) {
		ArrayList <String> aL=new ArrayList<String>();
		LinkedList <String> lL=new LinkedList<String>();
		String str="TODO";
		int i=0;
		while(i<100000){
			
			aL.add(0, str);
			aL.remove(0);
			i++;
			lL.add(0, str);
			lL.remove(0);
			
		}
		long t1=0,t2=0;
		while(t1<=t2){
			t1=t2=0;
			t1-=System.nanoTime();
			aL.add(0, str);
			t1+=System.nanoTime();
			t2-=System.nanoTime();
			lL.add(0, str);
			t2+=System.nanoTime();
		}
		System.out.println(t2);
		int n=1000;
		{
			
			int [] intArray=new int[n];
			int [] intResArray=new int[n];
			t1=0;
			t1-=System.nanoTime();
			System.arraycopy(intArray, 0, intResArray, 0, n);
			t1+=System.nanoTime();
			t2=0;
			t2-=System.nanoTime();
			for (int j = 0; j < intResArray.length; j++) {
				intResArray[j]=intArray[j];
				
			}
			t2+=System.nanoTime();
			System.out.println((double)t2/t1);
		}
		n=100_000;
		{
			
			int [] intArray=new int[n];
			int [] intResArray=new int[n];
			t1=0;
			t1-=System.nanoTime();
			System.arraycopy(intArray, 0, intResArray, 0, n);
			t1+=System.nanoTime();
			t2=0;
			t2-=System.nanoTime();
			for (int j = 0; j < intResArray.length; j++) {
				intResArray[j]=intArray[j];
				
			}
			t2+=System.nanoTime();
			System.out.println((double)t2/t1);
		}

		n=10_000_000;
		{
			
			int [] intArray=new int[n];
			int [] intResArray=new int[n];
			//System.out.println(intArray.length);
			t1=0;
			t1-=System.nanoTime();
			System.arraycopy(intArray, 0, intResArray, 0, n);
			t1+=System.nanoTime();
			t2=0;
			t2-=System.nanoTime();
			for (int j = 0; j < intResArray.length; j++) {
				intResArray[j]=intArray[j];
				
			}
			t2+=System.nanoTime();
			System.out.println((double)t2/t1);
		}
//		n=100_000_000;
//		{
//			
//			int [] intArray=new int[n];
//			int [] intResArray=new int[n];
//			t1=0;
//			t1-=System.nanoTime();
//			System.arraycopy(intArray, 0, intResArray, 0, n);
//			t1+=System.nanoTime();
//			t2=0;
//			t2-=System.nanoTime();
//			for (int j = 0; j < intResArray.length; j++) {
//				intResArray[j]=intArray[j];
//				
//			}
//			t2+=System.nanoTime();
//			System.out.println((double)t2/t1);
//		}
		
		{
			System.gc();
			long usedMB1 = (-Runtime.getRuntime().freeMemory()+Runtime.getRuntime().totalMemory());
			TreeMap<Integer,Integer> aLL=new TreeMap<Integer,Integer>();
			int k=0;
			for (int j = 0; j < 1000; j++) {
				aLL.put(new Integer(j),new Integer(j));
				//k+=aLL.get(i);
			}
			long usedMB2 = (-Runtime.getRuntime().freeMemory()+Runtime.getRuntime().totalMemory());
			System.out.println(usedMB2-usedMB1);
			//System.out.println(aLL);
		}
	    
		{
			System.gc();
			long usedMB1 = (-Runtime.getRuntime().freeMemory()+Runtime.getRuntime().totalMemory());
			Integer[] aLL=new Integer[1000];
//		
			long usedMB2 = (-Runtime.getRuntime().freeMemory()+Runtime.getRuntime().totalMemory());
			System.out.println(usedMB2-usedMB1);
			System.out.println(aLL);
		}
	}
	
}
